package com.sunny.ynhz.model;

import android.content.Context;

import com.sunny.ynhz.api.HttpManager;
import com.sunny.ynhz.api.subscriber.ApiSubscriber;
import com.sunny.ynhz.bean.StandardBean;
import com.sunny.ynhz.utils.SPUtil;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by huhuan123 on 2018/8/9.
 *
 * @describe TODO
 */

public class ProblemStandModel {
    IProblemTypeResultView iProblemTypeResultView;
    Context context;

    public ProblemStandModel(IProblemTypeResultView iProblemTypeResultView, Context context) {
        this.iProblemTypeResultView = iProblemTypeResultView;
        this.context = context;
    }

    public void getStandData(String time, String type) {
        HttpManager.getInstance().getProblemStandardMsg(time, SPUtil.get("userId", "").toString(), type).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new ApiSubscriber(context, new ApiSubscriber.HttpOnResultListener<StandardBean>() {
            @Override
            public void onNext(StandardBean standardBean) {
                iProblemTypeResultView.onSuccess(standardBean.getDate());
            }

            @Override
            public void onCompleted() {


            }

            @Override
            public void onstart() {
                iProblemTypeResultView.onStartLoad();
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                iProblemTypeResultView.onFail();

            }
        }));
    }
}